import React from 'react';
import useLogin from '../hooks/useLogin';
import { navigate } from 'gatsby';

export default function PrivateRoute({component: Comp, ...rest}) {
  const [isLogin, loading] = useLogin()
  if (loading) return null
  if (isLogin) return <Comp {...rest}></Comp>
  navigate("/login")
  return null
}